package net.khoroshev.dveri.domain;

import java.util.Date;

import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.Index;
import com.googlecode.objectify.annotation.OnSave;

@Entity
@Index
public class NewsArticle {
	@Id private Long id;
	private String title;
	private String spoiler;
	private String body;
	private boolean enabled = true;
	private Date created = new Date();
	private Date modified;
	public String getTitle() {
		return title;
	}
	public NewsArticle setTitle(String title) {
		this.title = title;
		return this;
	}
	public String getSpoiler() {
		return spoiler;
	}
	public NewsArticle setSpoiler(String spoiler) {
		this.spoiler = spoiler;
		return this;
	}
	public String getBody() {
		return body;
	}
	public NewsArticle setBody(String body) {
		this.body = body;
		return this;
	}
	public boolean isEnabled() {
		return enabled;
	}
	public NewsArticle setEnabled(boolean enabled) {
		this.enabled = enabled;
		return this;
	}
	public Date getCreated() {
		return created;
	}
	public NewsArticle setCreated(Date created) {
		this.created = created;
		return this;
	}
	public Date getModified() {
		return modified;
	}
	public NewsArticle setModified(Date modified) {
		this.modified = modified;
		return this;
	}
	public Long getId() {
		return id;
	}
	@OnSave void onSave() {
		modified = new Date();
	}
	@Override
	public String toString() {
		return "NewsArticle [id=" + id + ", title=" + title + ", spoiler="
				+ spoiler + ", body=" + body + ", enabled=" + enabled
				+ ", created=" + created + ", modified=" + modified + "]";
	}
	
}
